home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 January / macformat-033.iso / mac / Shareware City / Developers / ABox.v1.8 / CPlus Files / ABUEnvQD.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-23  |  5.2 KB  |  220 lines  |  [TEXT/MMCC]

  1. /*    
  2.     Copyright © 1991-1995 by TopSoft Inc.  All rights reserved.
  3.  
  4.     You may distribute this file under the terms of the TopSoft
  5.     Artistic License, accompanying this package.
  6.     
  7.     This file was developed by George (ty) Tempel in connection with TopSoft, Inc..
  8.     See the Modification History for more details.
  9.  
  10. Product
  11.     About Box
  12.  
  13. FILE
  14.     ABUEnvQD.c
  15.  
  16. NAME
  17.     ABUEnvQD.c, part of the ABox project source code,
  18.     responsible for mix-in handling the AboutBox QD environment stuff.
  19.  
  20. DESCRIPTION
  21.     This file contains defines for the about box modules.
  22.     
  23. DEVELOPED BY
  24.     George (ty) Tempel                netromancr@aol.com
  25.     All code in this file, and its associated header file was
  26.     Created by George (ty) Tempel in connection with the TopSoft, Inc.
  27.     "FilterTop" application development, except where noted.
  28.  
  29. CARETAKER - George (ty) Tempel <netromancr@aol.com>
  30.      Please consult this person for any changes or suggestions to this file.
  31.  
  32. MODIFICATION HISTORY
  33.  
  34.     dd mmm yy    -    xxx    -    patchxx: description of patch
  35.     12-aug-94    -    ty    -    initial version created/released
  36.     10-mar-95    -    ty    -    1.2 addition of various static methods moved from
  37.                                 ABObject; addition of method for examining
  38.                                 the port, active screen, and pixel depth
  39.     23-may-95    -    ty    -    changes for compatibility with the CodeWarrior CW6
  40.                             release and the associated Universal Headers from Apple:
  41.                             most methods that returned references now have "Ref" at
  42.                             the end of their methods names to prevent possible collisions
  43.                             with datatypes and classes of the same name (older versions
  44.                             of the compiler didn't have a problem with this).
  45.  
  46. */
  47.  
  48. /*===========================================================================*/
  49.  
  50. /*======= Segmentation directives ========*/
  51.  
  52. #ifdef USE_MANUAL_SEGMENTATION
  53. #pragma segment ty
  54. #endif
  55.  
  56. /*============ Header files ==============*/
  57.     
  58. #include     "ABUEnvQD.h"
  59.  
  60. /*=============== Globals ================*/
  61.  
  62. /*================ CODE ==================*/
  63.  
  64.  
  65. /*=============================== ABUEnvQD::ABUEnvQD ================================*/
  66. ABUEnvQD::ABUEnvQD(void)
  67. {
  68.     mVersion = 0;
  69. }    // end ABUEnvQD
  70.  
  71.  
  72. /*=============================== ABUEnvQD::~ABUEnvQD ================================*/
  73. ABUEnvQD::~ABUEnvQD(void)
  74. {
  75.     this->Close();
  76. }    // end ~ABUEnvQD
  77.  
  78.  
  79.  
  80. /*=============================== ABUEnvQD::IsPresent ================================*/
  81. Boolean    ABUEnvQD::IsPresent(void)
  82. {
  83.     if (this->WasntCheckedRef())
  84.     {
  85.         if (this->GestaltAvailable())
  86.         {
  87.             (void)this->CheckGestalt(gestaltQuickdrawVersion);
  88.             this->SetVersion(this->GetResult());
  89.             
  90.             (void)this->CheckGestalt(gestaltQuickdrawFeatures);
  91.             this->IndicatorRef() = true;
  92.         } else {
  93.             this->IndicatorRef() = false;
  94.         } // end if else block
  95.         
  96.         this->CheckedRef() = true;
  97.  
  98.     } // end if block
  99.     return this->IndicatorRef();
  100. }    // end IsPresent
  101.  
  102.  
  103. /*=============================== ABUEnvQD::CheckVersion ================================*/
  104. long    ABUEnvQD::CheckVersion(void)
  105. {
  106.     if (this->WasntCheckedRef())
  107.         (void)this->IsPresent();
  108.     
  109.     return this->VersionRef();
  110. } // end of CheckVersion
  111.  
  112.  
  113.  
  114. /*=============================== ABUEnvQD::CheckFeatures ================================*/
  115. long    ABUEnvQD::CheckFeatures(void)
  116. {
  117.     if (this->WasntCheckedRef())
  118.         (void)this->IsPresent();
  119.     
  120.     return this->ResultRef();
  121. } // end of CheckFeatures
  122.  
  123.  
  124.  
  125. /*=============================== ABUEnvQD::HasColorQD ================================*/
  126. Boolean    ABUEnvQD::HasColorQD(void)
  127. {
  128.     return this->CheckVersion() >= gestalt8BitQD;
  129.  
  130. } // end of HasColorQD
  131.  
  132.  
  133.  
  134. /*=============================== ABUEnvQD::IsColorPort ==================================*/
  135. //
  136. //    returns true if the current GrafPtr supports color qd
  137. //
  138. Boolean
  139. ABUEnvQD::IsColorPort(void) const
  140. {
  141.     return ABUEnvQD::IsColorPort();
  142.     GrafPtr curPort = NULL;
  143.     ::GetPort(&curPort);
  144.     
  145.     return this->IsColorPort(curPort);
  146. }
  147.  
  148.  
  149.  
  150. /*=============================== ABUEnvQD::IsColorPort ==================================*/
  151. //
  152. //    returns true if the current GrafPtr supports color qd
  153. //
  154. Boolean
  155. ABUEnvQD::IsColorPort(void)
  156. {
  157.     GrafPtr curPort = NULL;
  158.     ::GetPort(&curPort);
  159.     
  160.     return ABUEnvQD::IsColorPort(curPort);
  161. }
  162.  
  163.  
  164.  
  165. /*=============================== ABUEnvQD::IsColorPort ==================================*/
  166. //
  167. //    returns true if the current GrafPtr supports color qd
  168. //
  169. Boolean
  170. ABUEnvQD::IsColorPort(GrafPtr inGrafPtr)
  171. {
  172.     // Highest 2 bits of rowBytes are  set for a Color GrafPort
  173.     if (inGrafPtr != NULL)
  174.         return ((inGrafPtr->portBits.rowBytes & 0xC000) == 0xC000);
  175.     else
  176.         return false;
  177. }
  178.  
  179.  
  180.  
  181.  
  182. /*=============================== ABUEnvQD::IsActiveScreenDevice ==================================*/
  183. //
  184. //    returns true if the device is the active device
  185. //
  186. //    is called by:
  187. //        various
  188. //
  189. Boolean
  190. ABUEnvQD::IsActiveScreenDevice(GDHandle inGDevice)
  191. {
  192.     if (inGDevice)
  193.         return (::TestDeviceAttribute(inGDevice, screenDevice) &&
  194.                 ::TestDeviceAttribute(inGDevice, screenActive));
  195.     else
  196.         return false;
  197. }
  198.  
  199.  
  200.  
  201. /*=============================== ABUEnvQD::GetPixelDepth ==================================*/
  202. //
  203. //    GetPixelDepth will return the depth, in pixels, of the
  204. //    given Graphics Device
  205. //
  206. short    
  207. ABUEnvQD::GetPixelDepth(GDHandle inDevice)
  208. {
  209.     
  210.     //    begin here...
  211.     
  212.     if (!inDevice)
  213.         return kABdefaultScreenDepth;
  214.  
  215.     return (*(*inDevice)->gdPMap)->pixelSize;
  216.     
  217. }    //    end of function GetPixelDepth()...
  218.  
  219.  
  220.